package com.dao.impl;

import com.bean.Bhcase;
import com.bean.Bhtopic;
import com.dao.BhtopicDao;
import com.util.AliPool;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class BhtopicDaoImpl implements BhtopicDao {
    QueryRunner runner =new QueryRunner();

    @Override
    public List<Bhtopic> queryBhtopic(String sql, Object... obj) throws Exception {
        List<Bhtopic> list = null;
        Connection conn= AliPool.getConn();
        list=runner.query(conn,sql,new BeanListHandler<Bhtopic>(Bhtopic.class),obj);
        conn.close();
        return list;
    }

    @Override
    public List<Bhtopic> selectBhtopic(String name,int id) throws Exception {
        String sql="select a.topIcID,a.uID,a.cType,a.cTrue,a.cPor,a.ca,a.cb,a.cc,a.cd from bhtopic a inner JOIN userkutopic b on a.topIcID=b.topIcID INNER JOIN usertopicku c ON b.utID=c.utID WHERE c.tname=? and c.uid=?";
        return queryBhtopic(sql,name,id);
    }
}
